--- Code for 'https://github.com/Frege/frege/issues/103 Issue 103'
module tests.comp.Issue103 where

--- Tail recursion must pass an updated context in each turn.
--- Note that the value that is finally shown is of type
--- > [[[ ... 𝖆 ... ]]]
--- where the 'Int' argument determines the number of @[]@ pairs.
--- In the 3.22 release, this works only when there is no tail recursion.
nested ∷ Show 𝖆  ⇒ Int →  𝖆  → String
nested 0 x = show x
nested n x = nested (n-1) (x,x)
                -- when polymorphic tail recursion works,
                -- the following line can be commented
                -- ++ ""

main [arg] = do
    println "module Stress where"
    print   "val = "
    println (nested (atoi arg) true)
main _ = main ["3"]
